import Vue from 'vue'
import Vuex from 'vuex'
import axios from 'axios'
Vue.use(Vuex)
const store = new Vuex.Store({
  state:{
    num:1,
    money:1000,
    eng:'abcdefgh'
  },
  getters:{
    mymoney({money}){
        return "$"+money
    },
    myeng({eng}){
        return eng.split('').reverse().join('')
    }
  },
  mutations:{
    addNum(state,pyload){
      state.num = state.num+pyload
    }
    ,reduceNum(state,pyload){
        state.num -=pyload;
    }
  },
  actions:{
      reduceNum(ctx,pyload){
        ctx.commit("reduceNum",pyload)
      },
    async  getnews(){
      return  axios.get('/api/getnews')
      }
  }
})
export default store;